'''
	Lists all the files in the folders and provide a complete url.
	This is further used when the text needs to parsed.
	The links are stored in the files - 'direct.txt'
'''

import subprocess
import os
import config as cg


def ls():
	logfile = open(cg.outerDirectoryUrl, "w")
	output, error = subprocess.Popen(
						["ls", cg.data], stdout=logfile,
						stderr=subprocess.PIPE).communicate()
	with open(cg.outerDirectoryUrl) as f:
		content = f.readlines()
	
	return;
						
						
def ls1():
	with open(cg.outerDirectoryUrl) as f:
		content = f.readlines()
			
	logfile = open(cg.directoryUrl, "w")
	for line in content:
		line = line.strip('\n')
		lis = os.listdir(cg.data + "/" + line)
		for item in lis:
			#print "data/" + line + "/" + item +"\n"
			logfile.write(cg.data + "/" + line + "/" + item +"\n")
	
						
ls()
ls1()
						
